import 'dart:convert';

void main(List<String> args) {
  String str = '{"name": "张三", "age": 20 }';
  print(str);
  print(json.decode(str));
  Map<String, dynamic> map = json.decode(str);
  print(map['name']);
  People p = People.fromJsonToClass(map);
  print(p.name);
}

class People {
  String? name;
  int? age;
  People({this.age, this.name});

  factory People.fromJsonToClass(Map<String, dynamic> map) {
    return People(name:map['name'],age: map['age']);
  }
}
